import {request} from '@umijs/max';
import * as API from "@/services";
import {JournalColumnCollection_JournalGroup} from "@/services";


export async function fav(
  type: "article" | "journal" | "column" | "period",   //收藏类型
  bizId: API.EntityId,
  unfav: boolean = false,  //取消收藏true, 收藏false
  journalId?: API.EntityId,
): Promise<API.RespResult<any>> {
  return request(`/api/v1/front-collection/${bizId}/${type}`, {
    method: unfav ? "DELETE" : "POST",
    params: {
      journalId,
    },
  });
}


export async function queryMineFavArticles(params: API.FrontCollectionArticlePageQueryParams): Promise<API.RespPageResult<API.FrontArticleCollection>> {
  return request('/api/v1/front-collection/mycollection/article', {
    params,
  });
}
export async function queryMineFavJournals(params: API.FrontCollectionJournalPageQueryParams): Promise<API.RespPageResult<API.FrontJournalCollection>> {
  return request('/api/v1/front-collection/mycollection/journal', {
    params,
  });
}
export async function queryMineFavColumns(params: API.FrontCollectionColumnPageQueryParams): Promise<API.RespPageResult<API.FrontJournalColumnCollection>> {
  return request('/api/v1/front-collection/mycollection/column', {
    params,
  });
}
export async function queryMineFavColumnsByJournal(params: API.FrontCollectionColumnByJournalQueryParams): Promise<API.RespListResult<API.JournalColumnCollection_JournalGroup>> {
  return request('/api/v1/front-collection/mycollection/column-by-journal', {
    params,
  });
}


export async function queryMineFavPeriods(params: API.FrontCollectionColumnPageQueryParams): Promise<API.RespPageResult<API.FrontJournalPeriodCollection>> {
  return request('/api/v1/front-collection/mycollection/period', {
    params,
  });
}

